package com.nexus.service.sys.mapper;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.nexus.core.service.mapper.IBaseMapper;
import com.nexus.core.sys.entity.SysUser;
import com.nexus.core.sys.dto.SysUserDTO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * 系统用户MAPPER接口
 *
 * @author 路正宁
 * @version 2023-03-16
 */
@Mapper
public interface SysUserMapper extends IBaseMapper<SysUser> {

    /**
     * 根据id获取系统用户
     *
     * @param id
     * @return
     */
    SysUserDTO findById(String id);

    /**
     * 根据id获取系统用户, 包括被删除的用户
     *
     * @param id 用户ID
     * @return {@link SysUserDTO}
     */
    SysUserDTO findByIdByAll(String id);

    /**
     * 获取系统用户列表
     *
     * @param queryWrapper
     * @return
     */
    IPage<SysUserDTO> findList(Page<SysUserDTO> page, @Param(Constants.WRAPPER) QueryWrapper queryWrapper);
    
    /**
     * 用户登录
     * @author luzhengning
     * @date 2023/3/20 15:45
     */
    SysUserDTO userLogin(@Param("loginName") String loginName, @Param("password") String password);

    /**
     * 修改密码
     * @author luzhengning
     * @date 2023/3/20 17:20
     */
    @Update({"UPDATE sys_user SET password=#{pwd} WHERE id=#{id}"})
    int updatePassword(@Param("id") String var1, @Param("pwd") String var2);

    /**
     * 恢复用户状态
     *
     * @param idList id集合
     * @return {@link SysUserDTO}
     * @author Liuwq
     * @date 2023/12/07
     */
    int recoveryUsers(@Param("idList") List<String> idList);

}
